package com.aduerr.v1shouyin.mvp.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import androidx.appcompat.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aduerr.v1shouyin.R;
import com.aduerr.v1shouyin.common.Constants;
import com.aduerr.v1shouyin.common.DatabaseManager;
import com.aduerr.v1shouyin.entity.CardType;
import com.aduerr.v1shouyin.entity.KaQuanHeXiaoEntity;
import com.aduerr.v1shouyin.entity.KaQuanXiangQingEntity;
import com.aduerr.v1shouyin.entity.KouBeiTicktEntity;
import com.aduerr.v1shouyin.entity.KouBeiUseEntity;
import com.aduerr.v1shouyin.entity.OtherCardEntity;
import com.aduerr.v1shouyin.entity.TransactionFlowEntity;
import com.aduerr.v1shouyin.print.PrinterWrapper;
import com.aduerr.v1shouyin.unioncard.BaseUnionActivity;
import com.aduerr.v1shouyin.util.SharedPreferencesUtils;
import com.aduerr.v1shouyin.util.ToastUtils;
import com.google.gson.Gson;
import com.orhanobut.hawk.Hawk;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author sanshui
 * @Describe 核销结果页面
 * creat at 2018/10/13 14:29
 */
public class CardUseSuccessNewActivity extends BaseUnionActivity {
    private static int defalutBackIconResID;
    static {
        defalutBackIconResID = R.drawable.img_back_new;
    }

    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.card_num)
    TextView tvFinishHexiao;
    //wx
    @BindView(R.id.ll_wx)
    LinearLayout llWx;
    @BindView(R.id.card_name)
    TextView tvWxCardName;
    @BindView(R.id.tv_type)
    TextView tvWxType;
    @BindView(R.id.card_time)
    TextView tvWxCardTime;
    //团购券 门票
    @BindView(R.id.ll_tuangou)
    LinearLayout llTuanGou;
    @BindView(R.id.tuangou_name)
    TextView tvTuanGouName;
    @BindView(R.id.tv_tuangou_type)
    TextView tvTuanGouType;
    @BindView(R.id.order_money)
    TextView tvTuanGouMoney;
    @BindView(R.id.order_state)
    TextView tvTuanGouState;
    @BindView(R.id.order_time)
    TextView tvTuanGouOderTime;
    @BindView(R.id.tv_tuangou_num)
    TextView tvTuGouOrderID;
    @BindView(R.id.ll_menpiao_order)
    RelativeLayout llMenPiaoOrder;
    //酒店
    @BindView(R.id.ll_jiudian)
    LinearLayout llJiuDian;
    @BindView(R.id.jiudian_name)
    TextView tvJiuDianName;
    @BindView(R.id.jiudian_money)
    TextView tvJiuDianMoney;
    @BindView(R.id.jiudian_state)
    TextView tvJiuDianState;
    @BindView(R.id.order_jiudian_time)
    TextView tvJiudianOrderTime;
    @BindView(R.id.jiudian_contract)
    TextView tvJiudianContract;
    @BindView(R.id.jiudian_ordernum)
    TextView tvJiuDianOrderNum;
    //礼品
    @BindView(R.id.ll_lipin)
    LinearLayout llLiPin;
    @BindView(R.id.order_name_lipin)
    TextView tvLiPinName;
    @BindView(R.id.lipin_name)
    TextView tvLiPinUserName;
    @BindView(R.id.lipin_time)
    TextView tvLiPinTime;
    @BindView(R.id.lipin_jifen_state)
    TextView tvLiPinJifen;
    //口碑
    @BindView(R.id.ll_koubei)
    LinearLayout llKouBei;
    @BindView(R.id.order_name_koubei)
    TextView tvKouBeiName;
    @BindView(R.id.tv_koubei_realmoney)
    TextView tvKouBeiRealMoney;
    @BindView(R.id.koubei_nowmoney)
    TextView tvKouBeiNowMoney;
    @BindView(R.id.koubei_shishou)
    TextView tvKouBeiShiShou;
    @BindView(R.id.order_type_koubei)
    TextView tvKouBeiType;
    @BindView(R.id.ll_koubei_about)
    LinearLayout llKouBeiAbout;
    //关于
    @BindView(R.id.rl_about)
    RelativeLayout rlAbout;
    @BindView(R.id.about_content)
    TextView tvAboutContent;
    @BindView(R.id.tv_card_num)
    TextView tvCardNum;
    @BindView(R.id.hexiao_person)
    TextView tvHeXiaoP;
    @BindView(R.id.hexiao_time)
    TextView tvHexiaoTime;
    @BindView(R.id.rl_state)
    RelativeLayout rlState;
    @BindView(R.id.hexiao_state)
    TextView tvHeXiaoState;
    @BindView(R.id.tv_toolbar_title)
    TextView tvToolbarTitle;
    String type;
    //21  34  8
    OtherCardEntity otherCardEntity;
    //WX
    KaQuanXiangQingEntity.DataBean.ListBean kaquanxiangqingEntity;
    //koubei
    KouBeiUseEntity kouBeiUseEntity;
    //卡券码
    String erWeiMaResult;
    @BindView(R.id.ll_add)
    LinearLayout llAdd;
    @BindView(R.id.rl_needpay)
    RelativeLayout rl_needpay;
    @BindView(R.id.tv_jine)
    TextView tvNeedPay;
    @BindView(R.id.ll_print)
    LinearLayout ll_print;
    @BindView(R.id.btn_topay)
    Button btnToPay;
    //核销之后拿的
    KaQuanHeXiaoEntity kaQuanHeXiaoEntity;

    KouBeiTicktEntity.DataBean kouDataBean;
    private String[] content = new String[20];
    private String shopName;

    String cardMemberName = "";//会员次卡用的会员名
    String cardMemberPhone = "";//会员次卡用会员电话
    String cardSurpluscount = "";//会员次卡剩余次数

    @Override
    protected int getLayoutId() {
        return R.layout.activity_card_use_new_success;
    }

    @Override
    protected void initBase() {
        super.initView();
        ButterKnife.bind(this);
        initToolbarWithBack(0);
        initDate();
    }

    public void initToolbarWithBack(int backResId) {
        tvToolbarTitle.setText("卡券详情");
        if(mToolbar != null) {
            int rid = backResId == 0 ? defalutBackIconResID : backResId;
            mToolbar.setNavigationIcon(rid);
            mToolbar.setNavigationOnClickListener(v -> finish());
        }
    }

    private void initDate() {
        type = getIntent().getStringExtra("type");
        erWeiMaResult = getIntent().getStringExtra("erWeiMaResult");
        kaQuanHeXiaoEntity = (KaQuanHeXiaoEntity) getIntent().getSerializableExtra(
                "kaquan");
        if(CardType.WX.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.VISIBLE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            kaquanxiangqingEntity =
                    (KaQuanXiangQingEntity.DataBean.ListBean) getIntent().getSerializableExtra("Data");
            tvWxCardName.setText(kaquanxiangqingEntity.getName());
            tvWxCardTime.setText(kaquanxiangqingEntity.getBegintime().split(" ")[0] +
                    "~" + kaquanxiangqingEntity.getEndtime().split(" ")[0]);

            shopName = (String) kaquanxiangqingEntity.getShopname();
            if(TextUtils.isEmpty(shopName) || shopName == null) {
                shopName = Hawk.get("shopname");
                if(TextUtils.isEmpty(shopName)){
                    shopName = Hawk.get("company","");
                }
            }
            content[9] = shopName;
            if("0".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("优惠券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.y_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(erWeiMaResult);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                btnToPay.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.GONE);
            }
            if("1".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("抵用券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.d_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(erWeiMaResult);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                btnToPay.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.GONE);
            }
            if("2".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("折扣券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.z_color));
//                llAdd.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.VISIBLE);
                rlAbout.setVisibility(View.GONE);
                ll_print.setVisibility(View.GONE);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                tvNeedPay.setText(kaQuanHeXiaoEntity.getData().getNeedpay());
                tvCardNum.setText(erWeiMaResult);
            }
            if("3".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("代金券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.d_color));
//                llAdd.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.VISIBLE);
                tvNeedPay.setText(kaQuanHeXiaoEntity.getData().getNeedpay());
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                rlAbout.setVisibility(View.GONE);
                ll_print.setVisibility(View.GONE);
                tvCardNum.setText(erWeiMaResult);
            }
            if("4".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("礼品券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.l_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(erWeiMaResult);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                btnToPay.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.GONE);
            }
            if("5".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("团购券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.t_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(erWeiMaResult);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                btnToPay.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.GONE);
            }

            if("6".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("次卡");
                tvWxType.setBackgroundColor(Color.parseColor("#65B45B"));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(erWeiMaResult);
                tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getSiteusername());
                tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
                btnToPay.setVisibility(View.GONE);
                rl_needpay.setVisibility(View.GONE);
                //次卡三期
                cardMemberName = kaQuanHeXiaoEntity.getData().getVipName();
                cardMemberPhone = kaQuanHeXiaoEntity.getData().getVipPhone();
                cardSurpluscount = kaQuanHeXiaoEntity.getData().getRemainCount();
            }
        }
        if(CardType.JIUDIAN.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.VISIBLE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            otherCardEntity = (OtherCardEntity) getIntent().getSerializableExtra("Data");
            rlAbout.setVisibility(View.GONE);
//          tvAboutContent.setText(otherCardEntity.getData().getExplain());
            rlState.setVisibility(View.GONE);
            tvJiuDianName.setText(otherCardEntity.getData().getUserName());
            tvJiuDianMoney.setText(otherCardEntity.getData().getOrderMoney());
            tvJiudianOrderTime.setText(otherCardEntity.getData().getCreatetime());
            tvJiuDianState.setText(otherCardEntity.getData().getOrderState());
            tvJiuDianOrderNum.setText(otherCardEntity.getData().getOrderID());
            tvCardNum.setText(erWeiMaResult);
            tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
            tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
            btnToPay.setVisibility(View.GONE);
            rl_needpay.setVisibility(View.GONE);
            if("0".equals(otherCardEntity.getData().getOrderState())) {
                tvJiuDianState.setText("未付款");
            } else if("1".equals(otherCardEntity.getData().getOrderState())) {
                tvJiuDianState.setText("已支付");
            } else if("2".equals(otherCardEntity.getData().getOrderState())) {
                tvJiuDianState.setText("已到店");
            } else if("3".equals(otherCardEntity.getData().getOrderState())) {
                tvJiuDianState.setText("已离店");
            } else {
                tvJiuDianState.setText("已取消");
            }
            //少一个联系电话的字段
            tvJiudianContract.setText(otherCardEntity.getData().getPhone());
        }
        if(CardType.KOUBEI.name().equals(type)) {
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.VISIBLE);
            llTuanGou.setVisibility(View.GONE);
            tvKouBeiType.setText("口碑券");
            llKouBeiAbout.setVisibility(View.VISIBLE);
            kouDataBean =
                    (KouBeiTicktEntity.DataBean) getIntent().getSerializableExtra(
                            "koubei");
            kouBeiUseEntity = (KouBeiUseEntity) getIntent().getSerializableExtra("Data");
//                rlAbout.setVisibility(View.GONE);
            tvKouBeiName.setText(kouBeiUseEntity.getData().getItemName());
            tvKouBeiRealMoney.setText(kouBeiUseEntity.getData().getOriginalPrice());
            tvKouBeiNowMoney.setText(kouBeiUseEntity.getData().getCurrentPrice());
            tvKouBeiShiShou.setText(kouBeiUseEntity.getData().getCurrentPrice());

            tvCardNum.setText(erWeiMaResult);

            tvHeXiaoP.setText(kouBeiUseEntity.getData().getSiteUserName());
            tvHexiaoTime.setText(kouBeiUseEntity.getData().getUseDate());
            btnToPay.setVisibility(View.GONE);
            rl_needpay.setVisibility(View.GONE);
            rlAbout.setVisibility(View.GONE);
        }
        if(CardType.LIPIN.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.VISIBLE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            otherCardEntity = (OtherCardEntity) getIntent().getSerializableExtra("Data");
            tvLiPinName.setText(otherCardEntity.getData().getTitle());
            tvLiPinTime.setText(otherCardEntity.getData().getBegtime().split(" ")[0] +
                    "~" + otherCardEntity.getData().getEndtime().split(" ")[0]);
            tvLiPinJifen.setText(otherCardEntity.getData().getNeedIntegral());
            tvLiPinUserName.setText(otherCardEntity.getData().getUserName());
            rlAbout.setVisibility(View.GONE);
            tvCardNum.setText(erWeiMaResult);
            tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
            tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
            btnToPay.setVisibility(View.GONE);
            rl_needpay.setVisibility(View.GONE);
            shopName = Hawk.get("shopname");
            if(TextUtils.isEmpty(shopName)){
                shopName = Hawk.get("company","");
            }
        }
        //门票和团购
        if(CardType.MENPIAOANDTUANGOU.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.VISIBLE);
            otherCardEntity = (OtherCardEntity) getIntent().getSerializableExtra("Data");
            tvTuanGouName.setText(otherCardEntity.getData().getTitle());
            rlAbout.setVisibility(View.VISIBLE);
            tvAboutContent.setText(otherCardEntity.getData().getExplain());
            rlState.setVisibility(View.VISIBLE);
            tvTuGouOrderID.setText(kaQuanHeXiaoEntity.getData().getOrderID());
            tvTuanGouMoney.setText(otherCardEntity.getData().getOrderMoney());
            tvTuanGouState.setText(otherCardEntity.getData().getOrderState());
            if(erWeiMaResult.startsWith("34")) {
                tvTuanGouType.setText("门票");
                llMenPiaoOrder.setVisibility(View.GONE);
                tvTuanGouType.setBackgroundColor(getResources().getColor(R.color.d_color));
            }
            //差一个团购券
            if(erWeiMaResult.startsWith("25")) {
                tvTuanGouType.setText("团购券");
                tvTuanGouType.setBackgroundColor(getResources().getColor(R.color.t_color));
            }
            tvCardNum.setText(erWeiMaResult);
            tvHeXiaoP.setText(kaQuanHeXiaoEntity.getData().getMembername());
            tvHexiaoTime.setText(kaQuanHeXiaoEntity.getData().getTousedate());
            btnToPay.setVisibility(View.GONE);
            rl_needpay.setVisibility(View.GONE);
            if("1".equals(otherCardEntity.getData().getType())) {
                if("0".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("待支付");
                } else if("1".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已支付");
                } else if("2".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已支付");
                } else if("3".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已核销");
                } else {
                    tvTuanGouState.setText("已取消");
                }
            } else {
                if("0".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("未支付");
                } else if("1".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已支付");
                } else if("2".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已发货");
                } else if("3".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已完成");
                } else if("4".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("已失效");
                } else if("5".equals(otherCardEntity.getData().getOrderState())) {
                    tvTuanGouState.setText("申请退款");
                } else {
                    tvTuanGouState.setText("已退款");
                }
            }
        }
    }

    @OnClick({R.id.btn_topay, R.id.btn_finish, R.id.btn_print})
    public void OnViewClicked(View view) {
        switch(view.getId()) {
            case R.id.btn_topay:
                Intent intent = new Intent(CardUseSuccessNewActivity.this,
                        ScanningActivity.class);
                intent.putExtra(Constants.QRCODE_CAPUTER,
                        Constants.SCANCODECOLLECTION_QR);
                intent.putExtra(Constants.REALMONEY,
                        kaQuanHeXiaoEntity.getData().getNeedpay());
                startActivity(intent);
                finish();
                break;
            case R.id.btn_finish:
                finish();
                break;
            case R.id.btn_print:
//                toPrintDialog();
                content[0] = "卡券核销";
                if(CardType.WX.name().equals(type)) {
                    content[1] = tvWxCardName.getText().toString();
                    content[2] = tvWxType.getText().toString();
                    content[3] = tvWxCardTime.getText().toString();
                    content[4] = erWeiMaResult;
                    content[5] = tvHexiaoTime.getText().toString();
                    content[6] = tvHeXiaoP.getText().toString();
                    content[7] = tvAboutContent.getText().toString();

                    content[10] =cardMemberName;
                    content[11] =cardMemberPhone;
                    content[12] =cardSurpluscount;

                } else if(CardType.JIUDIAN.name().equals(type)) {
                    content[1] = tvJiuDianOrderNum.getText().toString();
                    content[2] = tvJiuDianMoney.getText().toString();
                    content[3] = tvJiuDianState.getText().toString();
                    content[4] = tvJiudianContract.getText().toString();
                    content[5] = tvJiudianOrderTime.getText().toString();
                    content[6] = tvHexiaoTime.getText().toString();
                    content[7] = tvHeXiaoP.getText().toString();
                } else if(CardType.KOUBEI.name().equals(type)) {
                    content[1] = tvKouBeiName.getText().toString();
                    content[2] = tvKouBeiRealMoney.getText().toString();
                    content[3] = tvKouBeiNowMoney.getText().toString();
                    content[4] = tvKouBeiShiShou.getText().toString();
                    content[5] = erWeiMaResult;
                    content[6] = tvHexiaoTime.getText().toString();
                    content[7] = tvHeXiaoP.getText().toString();
                } else if(CardType.LIPIN.name().equals(type)) {
//                    content[1] = tvLiPinName.getText().toString();
//                    content[2] = tvLiPinTime.getText().toString();
//                    content[3] = tvLiPinJifen.getText().toString();
//                    content[4] = tvLiPinUserName.getText().toString();
//                    content[5] = erWeiMaResult;
//                    content[6] = tvHexiaoTime.getText().toString();
//                    content[7] = tvHeXiaoP.getText().toString();

                    content[1] = tvLiPinName.getText().toString();
                    content[2] = "礼品券";
                    content[3] = tvLiPinTime.getText().toString();
                    content[4] = tvCardNum.getText().toString();
                    content[5] = tvHexiaoTime.getText().toString();
                    content[6] = tvHeXiaoP.getText().toString();
                    content[7] = tvAboutContent.getText().toString();

                } else if(CardType.MENPIAOANDTUANGOU.name().equals(type)) {
                    content[1] = tvTuanGouName.getText().toString();
                    content[2] = tvTuGouOrderID.getText().toString();
                    content[3] = tvTuanGouMoney.getText().toString();
                    content[4] = tvTuanGouState.getText().toString();
                    content[5] = tvTuanGouOderTime.getText().toString();
                    content[6] = erWeiMaResult;
                    content[7] = tvHexiaoTime.getText().toString();
                    content[8] = tvHeXiaoP.getText().toString();
                }
                cantoprintlastorder();
                break;
        }
    }

    //判断是否可以打印
    private void cantoprintlastorder() {

        int printpage = (int) SharedPreferencesUtils.getParam(this, "printpage", 1);
        if(printpage == 0) {
            ToastUtils.showToast(this, "打印张数设置为不打印,请先设置打印张数!!");
            return;
        }
        if(content != null && content.length > 0) {
//            if(CardType.WX.name().equals(type)) {
////                print(null, content, Constants.PRINT_WX, printpage);
//                PrinterWrapper.printHxDetail(printpage,false,content);
//            } else if(CardType.JIUDIAN.name().equals(type)) {
//                print(null, content, Constants.PRINT_HOTEL, printpage);
//            } else if(CardType.KOUBEI.name().equals(type)) {
//                print(null, content, Constants.PRINT_KOUBEI, printpage);
//            } else if(CardType.LIPIN.name().equals(type)) {
////                print(null, content, Constants.PRINT_GIFT, printpage);
//                PrinterWrapper.printHx(false,printpage,content);
//            } else if(CardType.MENPIAOANDTUANGOU.name().equals(type)) {
//                print(null, content, Constants.PRINT_GROUP, printpage);
//            }
            PrinterWrapper.printHxDetail(printpage,false,content);
        }
        //签退流水使用
        String json = new Gson().toJson(content);
        TransactionFlowEntity entity = new TransactionFlowEntity();
        entity.setPrintType(8);
        entity.setJson(json);
        DatabaseManager.getInstance().insert(entity);
    }

    private void print(Bitmap logo, String[] content, int orderType, int printPage) {

        printOrder(logo, content, orderType, printPage);
    }

    private void printOrder(Bitmap logo, String[] content, int orderType, int printPage) {
        PrinterWrapper.printPosOrder(logo, content, orderType, printPage);
    }


}
